package com.smag.echarts.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.smag.common.core.domain.AjaxResult;
import com.smag.common.utils.StringUtils;
import com.smag.echarts.domain.EchartsPieNatural;
import com.smag.echarts.service.EchartsPieNaturalService;
import com.smag.echarts.mapper.EchartsPieNaturalMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author hzqhzq
* @description 针对表【echarts_pie_natural】的数据库操作Service实现
* @createDate 2023-04-21 15:51:28
*/
@Service
public class EchartsPieNaturalServiceImpl extends ServiceImpl<EchartsPieNaturalMapper, EchartsPieNatural>
    implements EchartsPieNaturalService{

    @Override
    public AjaxResult getNaturalList() {
        return AjaxResult.success(list());
    }

    @Override
    public List<EchartsPieNatural> selectEchartsPieNaturalList(EchartsPieNatural echartsPieNatural) {
        LambdaQueryWrapper<EchartsPieNatural> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(StringUtils.isNotEmpty(echartsPieNatural.getName()),EchartsPieNatural::getName,echartsPieNatural.getName());
        queryWrapper.like(ObjectUtils.isNotNull(echartsPieNatural.getValue()),EchartsPieNatural::getValue,echartsPieNatural.getValue());
        return list(queryWrapper);
    }

    @Override
    public AjaxResult selectEchartsPieNaturalById(Long id) {
        return AjaxResult.success(getById(id));
    }

    @Override
    public AjaxResult insertEchartsPieNatural(EchartsPieNatural echartsPieNatural) {
        if (save(echartsPieNatural)) {
            return AjaxResult.success();
        }
        return AjaxResult.error();
    }

    @Override
    public AjaxResult updateEchartsPieNatural(EchartsPieNatural echartsPieNatural) {
        if (updateById(echartsPieNatural)) {
            return AjaxResult.success();
        }
        return AjaxResult.error();
    }

    @Override
    public AjaxResult deleteEchartsPieNaturalByIds(Long[] ids) {
        if (getBaseMapper().deleteEchartsPieNaturalBatchByIds(ids) > 0) {
            return AjaxResult.success();
        }
        return AjaxResult.error();
    }
}




